<?php

Class Gantipassword extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->load->model('mprofile','',TRUE);
		$this->load->model('mgantipassword','',TRUE);
	}

	function index()
	{
		$this->tampil();
	}

	function tampil()
	{
		$username = $this->session->userdata('username');
		$ilc['profile'] = $this->mprofile->profile($username);
        $ilc['title']   = "Home &raquo Profile";
		$this->load->view('vgantipassword',$ilc);
	}

	function change()
	{
		$username  = $this->input->post('username');
		$pwd_lama  = md5($this->input->post('pwd_lama'));
		$pwd_baru  = md5($this->input->post('pwd_baru'));
		$pwd_baru2 = md5($this->input->post('pwd_baru2'));

		$cek       = $this->mgantipassword->cekpaslama($username,$pwd_lama);

		if($cek > 0){
			$this->mgantipassword->change_password($username,$pwd_baru);
			$this->session->set_flashdata('alert2','Berhasil Merubah Password!!');
		}else{
			$this->session->set_flashdata('alert1','Maaf Password Lama Anda Salah!!');
		}

		redirect('gantipassword');
	}
}